home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / readline.lha / readline / history.h < prev    next >
C/C++ Source or Header  |  1991-02-12  |  5KB  |  121 lines

  1. /* History.h -- the names of functions that you can call in history. */
  2.  
  3. typedef struct _hist_entry {
  4.   char *line;
  5.   char *data;
  6. } HIST_ENTRY;
  7.  
  8. /* For convenience only.  You set this when interpreting history commands.
  9.    It is the logical offset of the first history element. */
  10. extern int history_base;
  11.  
  12. /* Begin a session in which the history functions might be used.  This
  13.    just initializes the interactive variables. */
  14. extern void using_history ();
  15.  
  16. /* Place STRING at the end of the history list.
  17.    The associated data field (if any) is set to NULL. */
  18. extern void add_history ();
  19.  
  20. /* Returns the number which says what history element we are now
  21.    looking at.  */
  22. extern int where_history ();
  23.   
  24. /* Set the position in the history list to POS. */
  25. int history_set_pos ();
  26.  
  27. /* Search for STRING in the history list, starting at POS, an
  28.    absolute index into the list.  DIR, if negative, says to search
  29.    backwards from POS, else forwards.
  30.    Returns the absolute index of the history element where STRING
  31.    was found, or -1 otherwise. */
  32. extern int history_search_pos ();
  33.  
  34. /* A reasonably useless function, only here for completeness.  WHICH
  35.    is the magic number that tells us which element to delete.  The
  36.    elements are numbered from 0. */
  37. extern HIST_ENTRY *remove_history ();
  38.  
  39. /* Stifle the history list, remembering only MAX number of entries. */
  40. extern void stifle_history ();
  41.  
  42. /* Stop stifling the history.  This returns the previous amount the
  43.    history was stifled by.  The value is positive if the history was
  44.    stifled, negative if it wasn't. */
  45. extern int unstifle_history ();
  46.  
  47. /* Add the contents of FILENAME to the history list, a line at a time.
  48.    If FILENAME is NULL, then read from ~/.history.  Returns 0 if
  49.    successful, or errno if not. */
  50. extern int read_history ();
  51.  
  52. /* Read a range of lines from FILENAME, adding them to the history list.
  53.    Start reading at the FROM'th line and end at the TO'th.  If FROM
  54.    is zero, start at the beginning.  If TO is less than FROM, read
  55.    until the end of the file.  If FILENAME is NULL, then read from
  56.    ~/.history.  Returns 0 if successful, or errno if not. */
  57. extern int read_history_range ();
  58.  
  59. /* Append the current history to FILENAME.  If FILENAME is NULL,
  60.    then append the history list to ~/.history.  Values returned
  61.    are as in read_history ().  */
  62. extern int write_history ();
  63.  
  64. /* Append NELEMENT entries to FILENAME.  The entries appended are from
  65.    the end of the list minus NELEMENTs up to the end of the list. */
  66. int append_history ();
  67.  
  68. /* Make the history entry at WHICH have LINE and DATA.  This returns
  69.    the old entry so you can dispose of the data.  In the case of an
  70.    invalid WHICH, a NULL pointer is returned. */
  71. extern HIST_ENTRY *replace_history_entry ();
  72.  
  73. /* Return the history entry at the current position, as determined by
  74.    history_offset.  If there is no entry there, return a NULL pointer. */
  75. HIST_ENTRY *current_history ();
  76.  
  77. /* Back up history_offset to the previous history entry, and return
  78.    a pointer to that entry.  If there is no previous entry, return
  79.    a NULL pointer. */
  80. extern HIST_ENTRY *previous_history ();
  81.  
  82. /* Move history_offset forward to the next item in the input_history,
  83.    and return the a pointer to that entry.  If there is no next entry,
  84.    return a NULL pointer. */
  85. extern HIST_ENTRY *next_history ();
  86.  
  87. /* Return a NULL terminated array of HIST_ENTRY which is the current input
  88.    history.  Element 0 of this list is the beginning of time.  If there
  89.    is no history, return NULL. */
  90. extern HIST_ENTRY **history_list ();
  91.  
  92. /* Search the history for STRING, starting at history_offset.
  93.    If DIRECTION < 0, then the search is through previous entries,
  94.    else through subsequent.  If the string is found, then
  95.    current_history () is the history entry, and the value of this function
  96.    is the offset in the line of that history entry that the string was
  97.    found in.  Otherwise, nothing is changed, and a -1 is returned. */
  98. extern int history_search ();
  99.  
  100. /* Expand the string STRING, placing the result into OUTPUT, a pointer
  101.    to a string.  Returns:
  102.  
  103.    0) If no expansions took place (or, if the only change in
  104.       the text was the de-slashifying of the history expansion
  105.       character)
  106.    1) If expansions did take place
  107.   -1) If there was an error in expansion.
  108.  
  109.   If an error ocurred in expansion, then OUTPUT contains a descriptive
  110.   error message. */
  111. extern int history_expand ();
  112.  
  113. /* Extract a string segment consisting of the FIRST through LAST
  114.    arguments present in STRING.  Arguments are broken up as in
  115.    the shell. */
  116. extern char *history_arg_extract ();
  117.  
  118. /* Return the number of bytes that the primary history entries are using.
  119.    This just adds up the lengths of the_history->lines. */
  120. extern int history_total_bytes ();
  121.